#![allow(non_snake_case)]

use dioxus::prelude::*;

use crate::routes::Route;

#[component]
pub fn Login() -> Element {
    let mut account = use_signal(|| String::from(""));
    let mut password = use_signal(|| String::from(""));

    rsx! {
        div {
            h1 { "登录标题" }
            input {
                value: "{account}",
                oninput: move |event| account.set(event.value())
            }
            input {
                value: "{password}",
                oninput: move |event| password.set(event.value())
            }
            button {
                onclick: move |_| async move {
                    if crate::client::bz::login(account.to_string(), password.to_string()).await {}
                },
                "登录"
            }
        }
    }
}

#[component]
pub fn Home() -> Element {
    rsx! {
        Link { to: Route::Login {}, "Go to login" }
        "Homepage"
    }
}
